import React from 'react';
import { Layout, Dropdown, Button, Menu } from 'antd';
import { connect } from 'react-redux';
import {Link,withRouter} from 'react-router-dom'
import styles from './styles.module.less';

const { Header } = Layout;

const mapStateToProps = state => ({ user: state.user });
const mapDispatchToProps = dispatch => {
  return {
    login: dispatch.user.adminLogin,
  };  
};

const menu = (props) =>(
  <Menu>
    <Menu.Item key="logout">
      <Link to="/login">退出登录</Link>
    </Menu.Item>
  </Menu>
)

export default connect(
    mapStateToProps,mapDispatchToProps
)((props) => {
    return (
        <Header className={ styles.header }>
        <Dropdown overlay={menu(props)}>
          <p>欢迎您！{localStorage.getItem('name')}</p>
        </Dropdown>
          
        </Header>
    )
})
